#pragma once
#include "IMenuState.h"
#include "../particles/ParticleManager.h"

class EntityManager;
class CPlayer;
class CBall;
class CWall;
class CGorbi;
class CCannyble;
class CPowerUp;
class CAlly;
class CRunner;
class CTank;
class CStriker;
class CBomber;
class CPathHint;

class CGameState :
	public CIMenuState
{

private:
	CGameState(void) = default;
	virtual ~CGameState(void) = default;

	CGameState(const CGameState&) = delete;	
	CGameState& operator= (const CGameState&) = delete;	
	
	EntityManager*			m_pEntities = nullptr;
	
	CPlayer*				m_pPlayer1 = nullptr;
	CPlayer*				m_pPlayer2 = nullptr;
	CPlayer*				m_pPlayer3 = nullptr;
	CPlayer*				m_pPlayer4 = nullptr;

	int m_nRedScore = 0;
	int m_nBlueScore = 0;
	int m_nPlayerNumber = 1;
	int m_nEntitySpawnIndex = 0;
	float m_uGameTime = 300.0f;
	int m_nPowerupnumber = 0;
	bool m_bPause = false;
	bool m_bScored = false;
	bool m_bWin = false;
	bool m_bMiniGame = false;
	bool m_bmap1 = true;

	float m_fWinTimer = 5;
	float m_fPowerUpTimer = 10;

	CAlly*		testAlly;
	CBall*		testBall;
	CWall*		testWall;
	CPowerUp*	testPowerUp;
	CGorbi*		testGorbi;
	CCannyble*	testCannyble;
	CTank*		testTank;
	CStriker*	testStriker;

	CWall*		m_TopWall;
	CWall*		m_BotWall;
	CWall*		m_LeftWall;
	CWall*		m_RightWall;

	std::vector<CCannyble*> m_Cannys;
	CEmitter * hBlueScorePar;
	CEmitter * hRedScorePar;

	CPathHint* m_pPhint;

	CParticleManager* pParticleSys;


	//end game slate cursor.
	unsigned int m_cursor;

public:


	static CGameState* GetInstance(void);

	virtual void	Enter(void)					override;		
	virtual void	Exit(void)					override;		

	virtual bool	Input(void)					override;		
	virtual void	Update(float elapsedTime)	override;	
	virtual void	Render(void)				override;	

	// Accessors
	int GetRedScore() const { return m_nRedScore; }
	int GetBlueScore() const { return m_nBlueScore; }
	unsigned int GetCursor() const { return m_cursor; }
	bool GetMap(){ return m_bmap1; }

	// Mutators
	void SetRedScore(int score)		{ m_nRedScore = score; }
	void SetBlueScore(int score)		{ m_nBlueScore = score; }
	void SetCursor(unsigned int prmCursor) { m_cursor = prmCursor; }
	void SetMap(bool map){ m_bmap1 = map; }

	// Factory Methods
	void CreatePlayer(SGD::Point position, SGD::Size size, int type, bool team, int controller, SGD::Rectangle prmRect);
	Entity* CreateScorpSpear(Entity* pOwner, int level);
	Entity* CreateGoalie(Entity* pOwner);
	Entity* CreateCannyble(SGD::Point position, SGD::Size size);
	Entity* CreateBall(SGD::Point position, SGD::Size size);
	Entity* CreateWall(SGD::Point position, SGD::Size size, bool highLow);
	Entity* CreateGorbi(SGD::Point position, SGD::Size size);
	Entity* CreateAlly(SGD::Point position, SGD::Size size);
	void CreatePowerup(SGD::Point position, SGD::Size size, int type);
	void PassPlayers(CPlayer* p, int playernumber);
	void PassData(int redscore, int bluescore);
	Entity* CreatePunch(Entity* pOwner) const;

	void RedScore();
	void BlueScore();
	void ResetGame();
	void DeleteEntity(Entity* e);

};

